<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <include file="Public:header" />
    
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>

    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerButton.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script> 
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script> 
    <script src="__PUBLIC__/lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    
       var grid,mydialog;
        $(function ()
        {
       	 //工具栏按钮
            var toolbarOptions = {
            		 items: [
            		   <volist id="item" name="button" >
                  	       <neq name="item['name']|strtolower" value="public" >
                  	             <neq name="item['name']|strtolower" value="index" >
                  	                  <eq name="item['access']" value="1" >
                  	                      { text:"{$item['title']}",id:"{$item['name']}", click:toolbarBtnItemClick, img: "__ROOT__{$item['nodeicon']}"},
                  	                      { line: true },
                  	                  </eq>
                  	             </neq>
                  	       </neq>
                  	  </volist>
                  	{ line: true } 
               ]
            };
             grid=$("#maingrid").ligerGrid({
                columns: [
                { display: '名称', name: 'name', align: 'left', width: 200, minWidth: 60 },
                { display: '创建日期', name: 'create_time', minWidth: 140, render:function (rowdata, rowindex, value){return DateFormat(value,"yyyy-MM-dd ");} },
                { display: '状态', name: 'status',render:function (row){return (row.status ==true)?'<img src="__PUBLIC__/lib/ligerui/skins/icons/ok.gif">':'<img src="__PUBLIC__/lib/ligerui/skins/icons/lock.gif">';} },
                { display: '备注', name: 'deptDesc', align: 'left', width: 100, minWidth: 60 }
                ], 
                url:'__URL__/treeArray',alternatingRow: false,tree: { columnName: 'name',isExtend:false },
                width: '100%', pageSizeOptions: [5, 10, 15, 20], height: '97%',
                toolbar:toolbarOptions
            });
            
            $("#pageloading").hide();
          //  grid.collapseAll();
        });

        //工具条事件
        function toolbarBtnItemClick(item) {
            switch (item.id) {
                case "add":
                	add();
                    break;
                case "edit":
                	edit();
                    break;
                case "del":
                   del();
                    break;
                case "addButtons":
                    addButtons();
                	break;
                default:{
                	LG.tip("此方法没有定义,联系管理员设定按钮权限!");
                }
            }
        }
        
        function add(item)
        {
        	mydialog=$.ligerDialog.open({ url: '__URL__/add/id/0', height: 400, width: 400,
             	                  isResize: true,isHidden:false
          });
        }
        function edit(item)
        {
        	var selected = grid.getSelected();
            if (!selected) { $.ligerDialog.warn('请选择行!'); return }
            mydialog= $.ligerDialog.open({ url: '__URL__/edit/id/'+selected.id, height: 400, width: 400,
                          isResize: true,isHidden:false
         });
        }
            
              
        function del(item)
        {

        	var selected = grid.getSelected();
            if (!selected) { $.ligerDialog.warn('请选择行!'); return }
            $.ligerDialog.confirm('是否真的删除此记录:'+selected .name, function (yes){
            	if(yes){
       					$.get("__URL__/del/",{"id":selected.id},function(data){
       						grid.loadData();
       						LG.tip($.parseJSON(data).info)
       						});
           				}
              });
        }
        
        function save(url,dialog)
        {
        	var fn = dialog.frame.f_save();//subset || dialog.frame.window.f_subset; 
        	
		
        }

    </script>
</head>
<body style="overflow-x:hidden; padding:2px;">
<div class="l-loading" style="display:block" id="pageloading"></div>
 <div class="l-clear"></div>
    <div id="maingrid"></div>
  <div style="display:none;">
 
</div>
 
</body>
</html>
